
// Time to run: 1-2 minutes

*==================================================================
* Figure A.2: Mean road tolls and bus lance distances. 2008-2017
*==================================================================

use    "${dataout}MainDataset" , clear

keep if couple==1
keep if year>=2008 & year<=2017

label variable toll_fam_mean "Road toll (NOK)" 
label variable ptl_fam_km_mean "Bus lane (km)"

*=========================================================================================
// 1) Binscatter of the development in road toll/ptl over time
*=========================================================================================

local yvarlist toll_fam_mean ptl_fam_km_mean
foreach y in `yvarlist' {

local laby: variable label `y'

reg `y' year 
eststo

local coeff _b[year]
local fmtcoeff : dis %7.5f `coeff'
dis `fmtcoeff'
	
local ylab 	
local ytitle

if "`y'"=="ptl_fam_km_mean" {
	local ylab "ylab(0(0.2)1)"
	local ytitle "Bus lane (km)"
	}	
	
	if "`y'"=="toll_fam_mean" {
	local ylab "ylab(0(2)10)"
	local ytitle "Road toll (NOK)"
	}	
	
dis "`ylab'"

binscatter  `y' year    , ///
line(lfit)   discrete legend(off)  scale(1.3) lcolor(gs10)   ///
ytitle("`ytitle'") `ylab'   `xlab'  ///
xtitle("Year")  xlab(2008(1)2017)  ///
graphregion(color(white))   yscale(titlegap(1.5)) xscale(titlegap(1.5)) ///
subtitle("Coeff: `fmtcoeff'")

graph export  "${figures}FigureA2_`y'.pdf" ,  replace
graph export  "${figures}FigureA2_`y'.png" ,  replace
}


